# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=ocaml-tophide
_pkgname=tophide
pkgver=1.0.4
pkgrel=2
pkgdesc="Hide OCaml toplevel values whose name starts with an underscore"
url="https://github.com/mjambon/tophide"
arch="all !riscv64 !loongarch64" # ocaml
license="BSD-3-Clause"
makedepends="ocaml ocaml-compiler-libs ocaml-findlib"
options="!check"
source="$pkgname-$pkgver.tar.gz::https://github.com/mjambon/tophide/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	make
}

package() {
	export OCAMLFIND_DESTDIR="$pkgdir"/usr/lib/ocaml
	mkdir -vp "$OCAMLFIND_DESTDIR"
	make install
}

prepare_py_provides() {
	local datadir="${subpkgdir:-$pkgdir}"
	local pkgbasedir=${pkgbasedir:-"$startdir/pkg"}
	local controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}

	options_has "!tracedeps" && return 0

	ocaml4-abuild-find provides \
		"$datadir"/usr/lib/ocaml \
		"$controldir" \
		"$pkgver-r$pkgrel"
}

scan_python3_dependency() {
	local controldir="$2" datadir="$3"

	ocaml4-abuild-find requires \
		"$datadir"/usr/lib/ocaml \
		"$controldir"
}

sha512sums="
9dafd73463f349e77b410e8df56966812752e78f08ad6ec5f1f13958beb374f8396fd05233b6499b0b941dc9ee5ca0d96e19041fc9b28c125692c8abf693734c  ocaml-tophide-1.0.4.tar.gz
"
